package jike.demo51;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @param
 * @author oyz
 * @version 1.0.4
 * @description: TODO
 * @date 2023/7/18 21:38
 */
public class Demo {


    public static void main(String[] args) {
        List<Student> data = new ArrayList<>();
        data.add(new Student(18,"oyz"));
        data.add(new Student(20,"lxz"));
        data.sort((o1, o2) -> o2.age-o1.age);

        System.out.println(data);
    }


    static class Student{
        private int age;

        private String name;

        public Student(int age, String name) {
            this.age = age;
            this.name = name;
        }

        @Override
        public String toString() {
            return "Student{" +
                    "age=" + age +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}
